package models;

import java.util.List;

import javax.persistence.*;

import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.*;

import com.avaje.ebean.*;
@Entity
public class User extends Model {
	public static Model.Finder<String,User> find = new Model.Finder<String,User>(String.class, User.class);
	
	@Id
	public int id;
	@Constraints.Required
    @Formats.NonEmpty
	public String name;
	@Constraints.Required
    @Formats.NonEmpty
    public String password;
	public String nr_karty;

	  public static User authenticate(String email, String password) {
	        return find.where()
	        	.eq("password", password)
	            .findUnique();
	    }

	    public static boolean isnull(){
	    	//List<User> users=find.all();
    	if(find.all().isEmpty()) return true;
    	else return false;
    	
    }

		  public static User checkUser(String name) {
			return find.where()
		        	.eq("name", name)
		            .findUnique();
		    }
	    
}
